package com.mowwang.file;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Flush {
    public static void main(String[] args) {
        FileWriter fileWriter=null;
        try {
            fileWriter=new FileWriter("b.txt");
            for (int i=0;i<100;i++)
            {

                fileWriter.write("I love you"+"\n");
                if (i%10==0){
                    fileWriter.flush();
                }
                fileWriter.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
